package cn.edu.ctbu.myfirstweb.dao;

import cn.edu.ctbu.myfirstweb.domain.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;

import javax.transaction.Transactional;
import java.io.Serializable;

public interface TeacherRepository extends JpaRepository<Teacher, Long>,
        JpaSpecificationExecutor<TeacherRepository>,
        Serializable {
    Teacher findByName(String name);

    @Modifying//通知SpringData这是一个update或delete操作
    @Transactional
//此操作需要使用事务
    void deleteByTid(Long tid);//该方法返回类型为Long是因为此处返回的是删除的记录

    Teacher findByTidAndAndPassword(Long tid, String password);
}